package com.zs.games.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.zs.games.enums.SourceTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;

@ApiModel(description = "用户评论实体类")
@Data
@TableName("user_comment")
public class UserComment {
    
    @ApiModelProperty(value = "评论id")
    @TableId(value = "comment_id", type = IdType.AUTO)
    private Integer commentId;
    
    @ApiModelProperty(value = "来源ID")
    private Integer sourceId;

    @ApiModelProperty(value = "来源类型 1:新闻，2:动态")
    private Integer sourceType;
    
    @ApiModelProperty(value = "评论的用户ID")
    private Integer userId;

    @ApiModelProperty(value = "评论的用户昵称")
    @TableField(exist = false)
    private String userNickname;
    
    @ApiModelProperty(value = "评论的内容")
    private String content;
    
    @ApiModelProperty(value = "评论时间")
    private Date createTime;
    @ApiModelProperty(value = "上级评论ID")
    private Integer lastCommentId;
    
    // Getters and setters


    public UserComment() {
    }

    public UserComment(Integer commentId, Integer sourceId, Integer userId, String content, SourceTypeEnum sourceType) {
        if (commentId != null){
            this.lastCommentId = commentId;
        }
        this.sourceId = sourceId;
        this.userId = userId;
        this.content = content;
        this.createTime = new Date();
        this.sourceType = sourceType.getValue();
    }
}
